//
//  AccountOrderDetailViewController.m
//  爱鲜蜂订单界面
//
//  Created by 刘栋 on 16/9/24.
//  Copyright © 2016年 刘栋. All rights reserved.
//

#import "AccountOrderDetailViewController.h"

#import <Masonry.h>
#import "NetworkingManager.h"
#import <AFNetworking.h>
#import "LFAccountOrderViewCell.h"
#import "LFaccountDetailViewController.h"

@interface AccountOrderDetailViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic,strong) NSArray *dataArray;

@property (nonatomic,weak) UIView *backGroundView;

@end

@implementation AccountOrderDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self createMainView];
    
    //创建tabelview
    [self createTableView];
    
}

- (void)createMainView
{
    UIView *view = [[UIView alloc] init];
    [self.view addSubview:view];
    
    [view mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.edges.equalTo(self.view);
        
    }];
    self.backGroundView = view;
    
    UIImageView *centerView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"v2_goods_empty"]];
    [view addSubview:centerView];
    
    [centerView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.center.equalTo(view);
        
    }];
    
    UILabel *descLable = [[UILabel alloc] init];
    descLable.text = @"还没有订单";
    [view addSubview:descLable];
    
    [descLable mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.centerX.equalTo(centerView);
        make.centerY.equalTo(centerView).offset(30);
        
    }];
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    if(section == 9){
        
        return 1;
    }
    else
    {
        return 10;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 0.01;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"cell被点击了");
    LFaccountDetailViewController *lvc = [[LFaccountDetailViewController alloc] init];
    [self.navigationController pushViewController:lvc animated:YES];
}

- (void)createTableView
{
    UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
    tableView.dataSource = self;
    tableView.delegate =self;
    [self.view addSubview:tableView];
    
    tableView.rowHeight = 170;
    //设置tableView的约束
    [tableView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.edges.equalTo(self.view);
        
    }];
    
    //去掉tableView的横线
    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    tableView.backgroundColor = [UIColor colorWithHex:0xefefef];
    
    UIImageView *downView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"v2_placeholder_square"]];
    downView.contentMode = UIViewContentModeScaleToFill;
    
    downView.frame = CGRectMake(0, 0, SCREEN_W, 150);
    tableView.tableFooterView = downView;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 10;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellId = @"cellId";
    LFAccountOrderViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
    if(cell == nil)
    {
        cell = [[LFAccountOrderViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellId];
    }
    //cell.textLabel.text = [NSString stringWithFormat:@"%ld",indexPath.row];
    
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    return cell;
}

- (void)createLable
{
    UILabel *lable = [[UILabel alloc] init];
    lable.text = [NSString stringWithFormat:@"第%ld业",self.number];
    [self.view addSubview:lable];
    
    [lable mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.centerX.equalTo(self.view.mas_centerX);
        make.top.offset(200);
        
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
